package com.acme.bankapp.domain.account;

import java.io.Serializable;

import com.acme.exceptions.NotEnoughFundsException;


@SuppressWarnings("serial")
public abstract class AbstractAccount implements Account, Serializable{

	protected StringBuffer accountInfo = new StringBuffer();
	protected int id;
	protected double balance;

	public AbstractAccount(double amount) {
		this.balance = ((amount >=0) ? amount : 0);
	}

	public double getBalance() {
		return this.balance;
	}

	public abstract void withdraw(double amount) throws NotEnoughFundsException;
	
	public abstract double maximumAmountToWithdraw();

	@Override
	public void deposit(double amount) {
		if(amount >= 0) {
			this.balance += amount;
			this.accountInfo.append("Deposited: " + amount + "\n");
		} else {
			throw new IllegalArgumentException("amount should be non-negative!");
		}
	}

	@Override
	public StringBuffer viewHistory() {
		return this.accountInfo;
	}

}
